package io.renren.modules.jxgk.controller;

import io.renren.common.annotation.SysLog;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import io.renren.modules.jxgk.entity.EvaluationTimeEntity;
import io.renren.modules.jxgk.service.EvaluationTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("EvaluationTime/")
public class EvaluationTimeController {

    @Autowired
    EvaluationTimeService evaluationTimeService;

    @RequestMapping("Select")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<EvaluationTimeEntity> cse = evaluationTimeService.queryList(query);
        int total = evaluationTimeService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(cse, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }
    @RequestMapping("/Delete")
    public R delete(@RequestBody String[] indexs){
        evaluationTimeService.deleteBatch(indexs);
        return R.ok();
    }
    @RequestMapping("/Insert")
    public R save(@RequestBody EvaluationTimeEntity ste){
        evaluationTimeService.save(ste);
        return R.ok();
    }
    @RequestMapping("/Info/{index}")
    public R info(@PathVariable("index") String index){
        EvaluationTimeEntity cse = evaluationTimeService.queryObject(index);
        return R.ok().put("EvaluationTime", cse);
    }
    @SysLog("修改用户")
    @RequestMapping("/Update")
    public R update(@RequestBody EvaluationTimeEntity cse){
        evaluationTimeService.update(cse);
        return R.ok();
    }
    @RequestMapping("{date}/Valid")
    public List<String> Valid(@PathVariable("date") String date){
        return evaluationTimeService.valid(date);
    }

}